#ifndef __CPPTUTORCOMMAND_H__
#define __CPPTUTORCOMMAND_H__
/*
    -> Command pattern is a behavioral design pattern.
    -> Encapsulates a command/ request. The command itself is treated as an object.
    -> Classes participating in a command pattern include:-
       * Command:- An abstract interface defining the execute method.
       * Concrete Commands:- Extend the Command interface and implements the execute method. Invokes the command on the receiver object.
       * Receiver:- Knows how to perform the command action.
       * Invoker:- Asks the command object to carry out the request.
       * Client:- Creates the commands and associates with the receiver.
    -> Some examples:- 
       * Used when history of requests is needed. (Stock orders executed for today)
       * Asynchronous processing. Commands need to be executed at variant times.
       * Installation wizards.
*/

#include <vector>

// Command interface
class Command
{
    public:
        virtual void execute() = 0;
};

// Receiver
class StockTrade {
    public:
        StockTrade();
       ~StockTrade();

        void buy();
        void sell();
};

// Concrete command 1
class BuyOrder : public Command {
    private:
        StockTrade* stock;
    public:
        BuyOrder(StockTrade* stock);
       ~BuyOrder ();
        void execute();
};

// Concrete command 2
class SellOrder : public Command {
    private:
        StockTrade* stock;
    public:
        SellOrder(StockTrade* stock);
       ~SellOrder ();
        void execute();
};

// Invoker
class StockAgent {
    public:
        StockAgent();
       ~StockAgent();
        void order( Command* command );
    private:
        // Looking at this command list gives
        // this order history
        std :: vector<Command*> commandList;
};

#endif //__CPPTUTORCOMMAND_H__
